<form method="post" id="country_member_search">
    <div class="country_member_search">
        <div class="country_member_search_input">
            <input type="text"  name="username" onfocus="removeLabel()" onblur="showLabel(this)" /> 
        </div>
        <div class="country_member_search_label" id="country_member_search_label"> Search Your Friends</div>
        <input type="hidden" name="search_member" value="1" />
        <div class="country_member_search_icon" onclick="submitFormSearchMember()"></div>
        
    </div>
</form>
<?php 
    if ($this->search == true):
?>
    <script type="text/javascript">
        function showMemberList(){
            var a = $$('.tab_layout_country_list_member');
            tabContainerSwitch(a[0], 'generic_layout_container layout_country_list_member');
        }
         
        setTimeout(showMemberList,1000);
    </script>
<?php endif;?>
<script type="text/javascript">
    function submitFormSearchMember(){
        document.getElementById("country_member_search").submit();
    }
    
    function removeLabel(){
        $('country_member_search_label').style.display = 'none';
    }
    function showLabel(el){
        var a = $$('.country_member_search_input').getElement('input');
        if (a.get('value') == "" ){
            $('country_member_search_label').style.display = 'block';
        }
    }
    

</script>
<div id="browsemembers_results" class="browsemembers_results">
<?php $viewer = Engine_Api::_()->user()->getViewer();?>
<?php $i = 0; ?>
<ul id="browsemembers_ul">
    <?php if ($this->paginator->count() <= 0) :?>
        <div  class="tip"><span>There is no member found.</span></div>
    <?php endif;?>
    <?php foreach( $this->paginator as $user ): ?>
    <li <?php if ($i % 2 == 0 ): ?> class="country_member_frist" <?php else: ?> class="country_member_second" <?php endif; ?>
    <?php $i++; ?>
      <?php 
        echo $this->htmlLink($user->getHref(), $this->itemPhoto($user, 'thumb.icon')) ?>
      <?php 
      $table = Engine_Api::_()->getDbtable('block', 'user');
      $select = $table->select()
        ->where('user_id = ?', $user->getIdentity())
        ->where('blocked_user_id = ?', $viewer->getIdentity())
        ->limit(1);
      $row = $table->fetchRow($select);
      ?>
      <?php if( $row == NULL ): ?>
        <?php if( $this->viewer()->getIdentity() ): ?>
        <div class='browsemembers_results_links'>
          
        </div>
      <?php endif; ?>
      <?php endif; ?>

        <div class='browsemembers_results_info'>
          <?php echo $this->htmlLink($user->getHref(), $user->getTitle()) ?>
          <?php echo $user->status; ?>
          <div>
          
              <?php $friendCount = Engine_Api::_()->country()->countFriend($user->getIdentity());
                if ($friendCount == 1 ) echo "1 Friend";
                else echo $friendCount." Friends";
               ?>
          </div>
          <?php if( $user->status != "" ): ?>
            <div>
              <?php echo $this->timestamp($user->status_date) ?>
            </div>
          <?php endif; ?>
          <?php
             if ($this->isManager == true):?>
            <div>
                <?php
                        if ($user->level_id != 1) {
                            if (!in_array($user->user_id,$this->listManager)) {
                            	echo $this->htmlLink(
                                            array(
                                            'route'			=>	'default',
                                            'module'        => 'country',                                   
                                            'controller'	=>	'manage',
                                            'action'		=>	'add-manager',
                                            'uid'			=>	$user->getIdentity(),
                                            'cid'           =>  $this->subject->country_id,
                                            'format'        =>  'smoothbox'
                                            ),
                                            $this->translate("Set Manager"),
                                            array(
                                                'class' => 'smoothbox',
                                            )
                                );
                             }  else {
                                if ($user->user_id != $viewer->user_id) {
                                	echo $this->htmlLink(
                                                array(
                                                'route'			=>	'default',
                                                'module'        => 'country',                                   
                                                'controller'	=>	'manage',
                                                'action'		=>	'remove-manager',
                                                'uid'			=>	$user->getIdentity(),
                                                'cid'           =>  $this->subject->country_id,
                                                'format'        =>  'smoothbox'
                                                ),
                                                $this->translate("Remove Manager"),
                                                array(
                                                    'class' => 'smoothbox',
                                                )
                                    );
                               } 
                             } 
                         }
                         ?>
            </div>
          <?php endif; ?>
        </div>
    </li>
    <?php endforeach; ?>
</ul>
<?php if( $this->paginator->count() > 20 ): ?>
  <div class='browsemembers_viewmore' id="browsemembers_viewmore">
    <?php echo $this->paginationControl($this->members, null, null, array(
      'pageAsQuery' => true,
      'query' => $this->formValues,
      //'params' => $this->formValues,
    )); ?>
  </div>
<?php endif; ?>

<script type="text/javascript">
  page = '<?php echo sprintf('%d', $this->page) ?>';
  totalUsers = '<?php echo sprintf('%d', $this->totalUsers) ?>';
  userCount = '<?php echo sprintf('%d', $this->userCount) ?>';
</script>
</div>
<style>
.browsemembers_results > ul > li
{
  overflow: hidden;
  border-top-width: 1px;
  margin-top: 10px;
  padding-top: 10px;
  height:80px;
}
.browsemembers_results > ul > li > a
{
  display: block;
  float: left;
}
html[dir="rtl"] .browsemembers_results > ul > li > a
{
  float: right;
}
.browsemembers_results > ul > li > a > img
{
  border: 1px solid $theme_photo_border_color;
}
.browsemembers_results div.browsemembers_results_info
{
  padding-left: 5px;
  overflow: hidden;
  max-width:280px;
}
html[dir="rtl"] .browsemembers_results div.browsemembers_results_info
{
  padding-left: 0px;
  padding-right: 5px;
}
.browsemembers_results div.browsemembers_results_info > a
{
  font-weight: bold;
}
.browsemembers_results div.browsemembers_results_info > div
{
  font-size: .8em;
  color: $theme_font_color_light;
}
.browsemembers_results div.browsemembers_results_links
{
  float: right;
  overflow: hidden;
  width: 175px;
  text-align: right;
}
html[dir="rtl"] .browsemembers_results div.browsemembers_results_links
{
  float: left;
  text-align: left;
}
.browsemembers_results_links a.buttonlink
{
  font-size: .8em;
  padding-top: 2px;
  padding-bottom: 3px;
}
.browsemembers_results div.browsemembers_viewmore,
.browsemembers_results div.browsemembers_loading
{
  margin-top: 10px;
  border-top-width: 1px;
  padding-top: 10px;
}
</style>